using System;

namespace MediaFramework
{
	/// <summary>
	/// Timestamp info class; this class contains all of the information about timestamps, durations, etc.
	/// </summary>
	public class TimestampInfo
	{
		public TimestampInfo ( ulong timescale, ulong durationInTimescaleUnits, ulong presentationTimestamp, ulong decodingTimestamp = 0x7FFFFFFFFFFFFFFF )
		{
			Timescale = timescale;
			DurationInTimescaleUnits = durationInTimescaleUnits;
			PresentationTimestamp = presentationTimestamp;
			DecodingTimestamp = decodingTimestamp == 0x7FFFFFFFFFFFFFFF ? PresentationTimestamp : decodingTimestamp;
		}

		/// <summary>
		/// Fetches the timescale for this sample.  The timescale represents a specific division of time.  For example,
		/// if we're processing 8000 khz audio, then the most appropriate timescale to use would be 8000.  By this method
		/// we avoid any/all rounding error.
		/// </summary>
		/// <value>
		/// The timescale.
		/// </value>
		public ulong Timescale { get; private set; }

		/// <summary>
		/// The duration of the sample in timescale units.  For example, if our timescale is 8000 hz, and we have a buffer
		/// that represents one-eighth of a second, then this would be set to 8000.
		/// </summary>
		/// <value>
		/// The duration in timescale units.
		/// </value>
		public ulong DurationInTimescaleUnits { get; private set; }

		/// <summary>
		/// Presentation timestamp.  This is the time at which the beginning of the sample should be presented by a renderer.
		/// As a stream progresses, these should increase monotonically.
		/// </summary>
		/// <value>
		/// The presentation timestamp.
		/// </value>
		public ulong PresentationTimestamp { get; private set; }

		/// <summary>
		/// A decoding timestamp.  This is the time at which this sample should be decoded by a decoder.  Most of the time this
		/// will be the same as a presentation time stamp.  For some codecs, like H.264, it may be necessary (see http://blog.monogram.sk/janos/2008/06/08/b-frames-in-directshow/
		/// for example.
		/// </summary>
		/// <value>
		/// The decoding timestamp.
		/// </value>
		public ulong DecodingTimestamp { get; private set; }
	}
}

